/**
 * @file Logical.h
 * @brief  GDR functions accessing and/or manipulating logical graph
 *         attributes.
 * @author Matt Stallmann @date 17 Dec 2001
 * $Id: Logical.h 10 2007-06-28 20:08:57Z mfms $
 */

/*
 *  Copyright (C) 1989, 2001, 2007  Matthias Stallmann, Prashant Hebbar.
 *  Contact: matt_stallmann@ncsu.edu
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program (file COPYING.txt); if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
 *  USA.
 */

#ifndef LOGICAL_H
#define LOGICAL_H

/* Access (read only) functions */

extern int max_vertex(void);
/**< returns the maximum index of a vertex */

extern int is_valid_vertex(vertex vx);
/**< returns TRUE iff vx is the index of a valid vertex */

extern vertex get_a_vertex(void);
/**< returns the index of a valid vertex if one exists, NULL_VERTEX otherwise */

extern int are_edges_equal(edge ej1, edge ej2);
/**< returns TRUE iff ej1 and ej2 are list pointers that identify the same
   edge (each adjacency list is stored as a list of pointers to edges, but
   the type 'edge' is a pointer to the list node in an adjacency list;
   thus, two distinct pointers may represent the same edge) */

extern vertex head(edge ej);
/**< returns the head of edge 'ej' (the vertex 'ej' is directed to if the
   graph is directed, arbitrary (higher index) if undirected */

extern vertex tail(edge ej);
/**< returns the tail of edge 'ej' (the vertex 'ej' is directed from if the
   graph is directed, arbitrary if (lower index) undirected */

extern edge first_edge(void);
/**< returns the first edge on the list of all edges of the graph */

extern edge next_edge(edge edj);
/**< returns the edge after 'edj' on the list of all edges */

extern vertex other_vertex(vertex vx, edge ej);
/**< returns the other endpoint of edge 'ej', where 'vx' is the current
   endpoint */

extern edge first_in_out_edge(vertex vx, int in);
/**< returns the first edge incident on vertex 'vx'; if the graph is
   directed, 'in' is TRUE if the first incoming edge is desired, FALSE if
   the first outgoing edge is desired */

extern edge next_in_out_edge(vertex vx, edge edj, char in);
/**< returns the next edge after 'edj' incident on vertex 'vx'; if the graph is
   directed, 'in' is TRUE if the next incoming edge is desired, FALSE if
   the next outgoing edge is desired */

extern char *vertex_label(vertex vx);
/**< returns the label of vertex 'vx' as an allocated string */

extern char *edge_label(edge ej);
/**< returns the label of edge 'ej' as an allocated string */

/****************************************************************************/
/* Modification functions */

extern void change_edge_label(edge ej, char *label);
/**< changes label of 'ej' to 'label' */

extern void change_vertex_label(vertex vx, char *label);
/**< changes label of 'vx' to 'label' */

extern edge add_edge(vertex vx1, vertex vx2, char *label);
/**< add an edge from vx1 to vx2 with the given label and return a pointer to
   its position in vx1's adjacency list */

extern void delete_edge(edge pt);
/**< deletes the edge 'pt' */

extern vertex add_vertex(int x, int y, char *label);
/**< add a new vertex with the given label at position (x,y) and return its
   index */

extern void delete_vertex(vertex vx);
/**< deletes the vertex 'vx' and all incident edges */

#endif
/** end of Logical.h **/

/*  [Last modified: 2007 06 28 at 19:22:52 GMT] */
